import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class SendEmail {


	final static String from = "Vincell <info@vincell.hu>";

	final static Properties properties = System.getProperties();

	static {
		properties.setProperty("mail.smtp.host", "localhost");	
		properties.setProperty("mail.user", "opencart");
		properties.setProperty("mail.password", "freebex08");
	}

	public static void send(final String mailSubject, final String mailText) {
		// Get the default Session object.
		final Session session = Session.getDefaultInstance(properties);

		try {
			final MimeMessage message = new MimeMessage(session);

			message.setFrom(new InternetAddress(from));
			message.addRecipient(Message.RecipientType.TO, new InternetAddress("info@vincell.hu"));
			message.setSubject(mailSubject/*, "utf-8"*/);
			message.setText(mailText/*, "utf-8"*/);

			// Send message
			Transport.send(message);
			System.out.println("ok");

		} catch (final MessagingException mex) {
			mex.printStackTrace();
		}
	}
}
